home *** CD-ROM | disk | FTP | other *** search
- Path: gail.ripco.com!mambuhl
- From: mambuhl@ripco.com (Martin Ambuhl)
- Newsgroups: comp.lang.c
- Subject: Re: Universal include fil
- Date: 26 Feb 1996 07:18:06 GMT
- Organization: Ripco Communications, Inc.
- Message-ID: <4grmre$3uu@gail.ripco.com>
- NNTP-Posting-Host: foley.ripco.com
-
- pahint@eunet.be (Pieter Hintjens)
- in <4gnjea$30m@news.Belgium.EU.net> writes:
-
- >I am working on a project to build a 'Universal Include File'.
- >The point is to encapsulate the peculiarities of every system
- >under the sun into one include file. Maybe this is not doable,
- >but I already have something halfway decent.
-
- >The UIF should include all the standard header files: certainly
- >all those defined in the ANSI C standard, plus those that are
- >common enough to be valuable. (E.g. socket interface files.)
-
- A few comments here:
- There is no conditional for the following
- >#include <fcntl.h>
- even though it is clearly _not_ a standard header.
- Since the other 9 headers in this group are standard headers,
- and since fcntl.h is not guaranteed to be present, I suggest
- a test for the implementation.
-
- The failure to include locale.h, iso646.h, wctype.h, and wchar.h is
- perhaps understandable, since many implementations will not have the
- last three (Amendment 1) headers and these 4 are of limited use to many
- programmers. I am a little suprised that this should be true for you as
- a .be domain programmer.
-
- However, I find the failure to include the standard headers assert.h,
- float.h, math.h, setjmp.h, and stddef.h a little hard to understand.
-
- It is not enough to just #include whatever headers are in some
- implementation. If your code actually uses any of the stuff associated
- with non-standard headers, you better supply some definition of how
- _other_ implementations can see the same code and do the "right" thing.
-
- Since different implementations will have different definitions of the
- non-standard `extensions', you will perhaps find this exercise worse
- than frustrating.
-
- > * Defines one or more of these symbols, for use in any non-portable
- > * code:
-
- You are missing many other common systems. Check the code for one that
- is missing (__GCC__) and you will find many of the useful ones that you
- have omitted.
-
- >#if (defined (__TURBOC__)) /* Borland Turbo-C uses this */
- ># include <alloc.h> /* name for its include file */
- >#else
- ># include <malloc.h>
- >#endif
-
- The above is a poor idea. There are several reasons. One is that
- Borland has long supplied a malloc.h and alloc.h. Check the contents of
- these. You will find that Borland's malloc.h includes alloc.h itself.
- Now, if you have included stdlib.h and stddef.h, you will not need
- malloc.h (or alloc.h) for any of NULL, ptrdiff_t, calloc(), free(),
- malloc(), or realloc().
-
- Unless you are handling legacy code, there is no reason to use
- malloc.h/alloc.h for any of the dangerous functions brk or sbrk.
-
- If you code has a prayer of portability you should not want -- and with
- adequate care or the right tools you will not need -- any of headcheck,
- heapfillfree, heapcheckfree, coreleft, _memavl() heapchecknode,
- heapwalk,
- or the abominatitions of the far versions [far*(), _f*()], huge versions
- [h*()] or near versions [_n*()] of the various standard and non-standard
- functions here.
-
- Nor will you need the struct [far]heapinfo.
-
- So just
- #include <stdlib.h>
- #include <stddef.h>
-
- And forget the malicious jokes <malloc.h> and <alloc.h>.
-
- --
- * Martin Ambuhl net: mambuhl@ripco.com
- * Chicago, IL (USA)
-